﻿using System;
using System.Collections.Generic;
using System.Text;

namespace StockTrader.BusinessService.DataContract.HnxInfo
{
    public class HnxStockData
    {
        public DateTime TradingDate { set; get; }
        public string Time { set; get; }
        public int StockId { set; get; }
        public string Code { set; get; }
        public int DateNo { set; get; }

        public decimal TotalListingQtty { set; get; }
        public int ReferenceStatus { set; get; }
        public int Status { set; get; }

        public int Ref { set; get; }
        public int Ceiling { set; get; }
        public int Floor { set; get; }

        public int Open { set; get; }
        public int Close { set; get; }
        public int High { set; get; }
        public int Low { set; get; }
        public int Avg { set; get; }

        public int BestOffer { set; get; }
        public long BestOfferQtty { set; get; }
        public long TotalOffer { set; get; }

        public int BestBid { set; get; }
        public long BestBidQtty { set; get; }
        public long TotalBid { set; get; }

        public int PriorClosePrice { set; get; }
        public int MatchPrice { set; get; }
        public long MatchQtty { set; get; }

        public long BidCount { set; get; }
        public long OfferCount { set; get; }
        public long TotalTradedQtty { set; get; }
        public decimal TotalTradedValue { set; get; }

        public int PtMatch { set; get; }
        public long PtMatchQtty { set; get; }
        public long PtTotalTradeQtty { set; get; }
        public decimal PtTotalTradeValue { set; get; }

        public long BuyCount { set; get; }
        public long SellCount { set; get; }
        public long BuyTradingQtty { set; get; }
        public decimal BuyTradingValue { set; get; }
        public long SellTradingQtty { set; get; }
        public decimal SellTradingValue { set; get; }

        public long FBuy { set; get; }
        public decimal FBuyValue { set; get; }
        public long FSell { set; get; }
        public decimal FSellValue { set; get; }
        public decimal FRemain { set; get; }
        public decimal FRoom { set; get; }

        public long TimeStamp { set; get; }

        public HnxStockData() { }

        public HnxStockData(DateTime date, string time, decimal id, string code, decimal dateno, decimal totallisting, decimal refstatus, decimal status, decimal open, decimal close, decimal high, decimal low, decimal avg, decimal bestoffer, decimal bestofferqtty, decimal totaloffer, decimal bestbid, decimal bestbidqtty, decimal totalbid, decimal priorcloseprice, decimal matchprice, decimal matchqtty, decimal bidcount, decimal offercount, decimal totaltrade, decimal totaltradevalue, decimal ptmatch, decimal ptmatchqtty, decimal pttotaltrade, decimal pttotalvalue, decimal buycount, decimal sellcount, decimal buytrading, decimal buytradingvalue, decimal selltrading, decimal selltradingvalue, decimal fbuy, decimal fbuyvalue, decimal fsell, decimal fsellvalue, decimal fremain, decimal froom)
        {
            this.TradingDate = date;
            this.Time = time;
            this.StockId = Convert.ToInt32(id);
            this.Code = code;
            this.DateNo = Convert.ToInt32(dateno);
            this.TotalListingQtty = totallisting;
            this.ReferenceStatus = Convert.ToInt32(refstatus);
            this.Status = Convert.ToInt32(status);
            this.Open = Convert.ToInt32(open);
            this.Close = Convert.ToInt32(close);
            this.High = Convert.ToInt32(high);
            this.Low = Convert.ToInt32(low);
            this.Avg = Convert.ToInt32(avg);
            this.BestOffer = Convert.ToInt32(bestoffer);
            this.BestOfferQtty = Convert.ToInt64(bestofferqtty);
            this.TotalOffer = Convert.ToInt64(totaloffer);
            this.BestBid = Convert.ToInt32(bestbid);
            this.BestBidQtty = Convert.ToInt64(bestbidqtty);
            this.TotalBid = Convert.ToInt64(totalbid);
            this.PriorClosePrice = Convert.ToInt32(priorcloseprice);
            this.MatchPrice = Convert.ToInt32(matchprice);
            this.MatchQtty = Convert.ToInt64(matchqtty);
            this.BidCount = Convert.ToInt64(bidcount);
            this.OfferCount = Convert.ToInt64(offercount);
            this.TotalTradedQtty = Convert.ToInt64(totaltrade);
            this.TotalTradedValue = totaltradevalue;
            this.PtMatch = Convert.ToInt32(ptmatch);
            this.PtMatchQtty = Convert.ToInt64(ptmatchqtty);
            this.PtTotalTradeQtty = Convert.ToInt64(pttotaltrade);
            this.PtTotalTradeValue = pttotalvalue;
            this.BuyCount = Convert.ToInt64(buycount);
            this.SellCount = Convert.ToInt64(sellcount);
            this.BuyTradingQtty = Convert.ToInt64(buytrading);
            this.BuyTradingValue =buytradingvalue;
            this.SellTradingQtty = Convert.ToInt64(selltrading);
            this.SellTradingValue = selltradingvalue;
            this.FBuy = Convert.ToInt64(fbuy);
            this.FBuyValue = fbuyvalue;
            this.FSell = Convert.ToInt64(fsell);
            this.FSellValue = fsellvalue;
            this.FRemain = fremain;
            this.FRoom = Convert.ToDecimal(froom);
            this.TimeStamp = DateTime.Now.Ticks;
        }

        #region IComparable Members

        public int CompareTo(object obj)
        {
            if ((StockId - ((HnxStockData)obj).StockId).Equals(0))
                return TotalTradedQtty.CompareTo(((HnxStockData)obj).TotalTradedQtty);
            else
                return StockId.CompareTo(((HnxStockData)obj).StockId);
        }

        public override bool Equals(object obj)
        {
            if (StockId.Equals(((HnxStockData)obj).StockId))
                return TotalTradedQtty.Equals(((HnxStockData)obj).TotalTradedQtty);
            else
                return StockId.Equals(((HnxStockData)obj).StockId);
        }
        #endregion

    }
}
